"""
Case Type   : datakit录制回放工具
Case Name   : 录制回放界面点击手动刷新按钮，刷新成功
Create At   : 2025/3/27
Owner       : @lonely-dance
Description :
    1.刷新录制回放界面
    2.清理环境
Expect      :
    1.成功
    2.成功
History     :
"""

import os
import re
import time
import unittest
from yat.test import Node
from yat.test import macro
from testcase.utils.CommonSH import CommonSH
from testcase.utils.Logger import Logger
from testcase.utils.datakit_api.CommonApi import CommonApi
from testcase.utils.datakit_api.DataMigration import DataMigrationApi
from testcase.utils.CommonDatakit import CommonDatakit
from testcase.utils.CommonMySQL import CommonMySQL


class Tools(unittest.TestCase):
    def setUp(self):
        self.log = Logger()
        self.log.info(f"-----{os.path.basename(__file__)} start-----")
        self.com_sh = CommonSH('PrimaryDbUser')
        self.token = self.com_sh.get_token_value(macro.DATAKIT_PASSWD)
        self.log.info(self.token)
        self.assertNotEqual("error", self.token)
        self.data_migration_api = DataMigrationApi(self.token)

    def test_transcribe_replay(self):
        text = '----step1:刷新录制回放页面 expect:成功----'
        self.log.info(text)
        response = self.data_migration_api.get_plugins_data_migration_transcribeReplay_list()
        self.log.info(response.json())
        self.assertEqual(200, response.json()['code'], '执行失败' + text)

    def tearDown(self):
        text = '----step2:清理环境----'
        self.log.info(text)
        self.log.info('----无需清理环境----')

        self.log.info(f"-----{os.path.basename(__file__)} finsh-----")
